﻿Namespace Security

    <AttributeUsage(AttributeTargets.Class Or AttributeTargets.Method, AllowMultiple:=False, Inherited:=True)> _
    Public NotInheritable Class AllowAnonymousAttribute
        Inherits Attribute
    End Class

    Public NotInheritable Class AutorizationSecurity
        Inherits AuthorizeAttribute
        Public Overrides Sub OnAuthorization(filterContext As AuthorizationContext)
            Dim skipAuthorization As Boolean = filterContext.ActionDescriptor.IsDefined(GetType(AllowAnonymousAttribute), True) OrElse filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(GetType(AllowAnonymousAttribute), True)
            If Not skipAuthorization Then
                MyBase.OnAuthorization(filterContext)
            End If
        End Sub
    End Class

End Namespace
